
$(function(){
    initGrant();
 })
 function initGrant() {
     $("#grant").dialog({
         title:'sdkjf',
         btnBind:function(){
             var rows01=$("#userTable").bootstrapTable("getSelections");
             var rows02=$("#roleTable").bootstrapTable("getSelections");
             var param="userId="+rows01[0].id+"&roleId="+rows02[0].id;
             $.post(ctx+"/sys/user/grant",param,function(msg){
                 $("#grant").dialog("close");
                 $("#userTable").bootstrapTable("refresh");
                 toastr.warning("信息提示",msg);
                 $("#roleTable").bootstrapTable("uncheckAll");//?
             },'text');
         }
     });
 }
/*tianjia*/
function prepareAdd() {
    $.post(ctx+"/sys/user/addInfo",param,function(msg){

    })
}

function grant(){
    var rows=$("#userTable").bootstrapTable("getSelections");
    if(rows.length!=1){
        swal("请选择一项且只能选择一项待授权！");
        return;
    }
    var userId=rows[0].id;
    var roleId=rows[0].roleId;
    //  alert("hello"+roleId);
    $("#roleTable").bootstrapTable("checkBy",{field:"id",values:[roleId]});
    $("#grant").dialog("open");
}


